package com.caigou.modules.famous.adpter

import android.graphics.Color
import android.text.TextUtils
import android.view.View
import android.widget.TextView
import com.caigou.modules.famous.R
import com.caigou.modules.famous.bean.ContestItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/12/08
 */
class PersonalItemAdapter(dataset: MutableList<ContestItemBean>) :
    BaseQuickAdapter<ContestItemBean, BaseViewHolder>(R.layout.item_personal_list, dataset) {

    override fun convert(holder: BaseViewHolder, item: ContestItemBean) {
        holder.setText(R.id.item_personal_tv_period, "第${item.period}期：")
        holder.setText(R.id.item_personal_tv_content, item.contentDetail)
        if (TextUtils.isEmpty(item.remark)) {
            holder.getView<TextView>(R.id.item_personal_tv_remark).visibility = View.GONE
        } else {
            holder.getView<TextView>(R.id.item_personal_tv_remark).visibility = View.VISIBLE
            holder.setText(R.id.item_personal_tv_remark, item.remark)
        }
        holder.setText(R.id.item_personal_tv_time, item.createTime)

        when (item.statusAward) {
            0 -> {
                holder.getView<TextView>(R.id.item_personal_tv_result).setTextColor(Color.parseColor("#4CAF50"))
                holder.setText(R.id.item_personal_tv_result, "未开奖")
            }
            1 -> {
                holder.getView<TextView>(R.id.item_personal_tv_result).setTextColor(Color.parseColor("#4CAF50"))
                holder.setText(R.id.item_personal_tv_result, "对")
            }
            2 -> {
                holder.getView<TextView>(R.id.item_personal_tv_result).setTextColor(Color.parseColor("#FE6880"))
                holder.setText(R.id.item_personal_tv_result, "错")
            }
        }
    }
}